package request

// RegisterFormWithPwd 使用密码
type RegisterFormWithPwd struct {
	Username string `form:"username" json:"username" binding:"required"`
	Password string `form:"password" json:"password" binding:"required"`
}

// GetMessages 自定义错误信息
func (r RegisterFormWithPwd) GetMessages() ValidatorMessages {
	// 全部小写
	return ValidatorMessages{
		"username.required": "用户名不能为空",
		"password.required": "密码不能为空",
	}
}

// RegisterFormWithEmail 使用邮箱
type RegisterFormWithEmail struct {
	Email string `form:"email" json:"email" binding:"required,validate_email"` // validate_phone 自定义校验器
	Code  string `form:"code" json:"code" binding:"required"`                  // code 验证码
}

// GetMessages 自定义错误信息
func (r RegisterFormWithEmail) GetMessages() ValidatorMessages {
	// 全部小写
	return ValidatorMessages{
		"email.required":       "邮箱不能为空",
		"email.validate_email": "邮箱格式不正确",
		"code.required":        "验证码不能为空",
	}
}

// RegisterFormWithPhone 使用手机号
type RegisterFormWithPhone struct {
	Phone string `form:"phone" json:"phone" binding:"required,validate_phone"` // validate_phone 自定义校验器
	Code  string `form:"code" json:"code" binding:"required"`                  // code 验证码
}

// GetMessages 自定义错误信息
func (r RegisterFormWithPhone) GetMessages() ValidatorMessages {
	// 全部小写
	return ValidatorMessages{
		"phone.required":       "手机号不能为空",
		"phone.validate_phone": "手机号格式不正确",
		"code.required":        "验证码不能为空",
	}
}

type LoginForm struct {
	Username string `form:"username" json:"username" binding:"required"`
	Password string `form:"password" json:"password" binding:"required"`
}

func (f LoginForm) GetMessages() ValidatorMessages {
	return ValidatorMessages{
		"username.required": "用户名不能为空",
		"password.required": "密码不能为空",
	}
}
